package com.jss.lanouhn.fristapp.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jss.lanouhn.fristapp.R;
import com.jss.lanouhn.fristapp.modles.TabNames;

/**PopWindowView的RecyclerView的适配器
 * Created by lanouhn on 16/8/25.
 */
public class PopViewAdapter extends BaseAdapter{
    private TabNames tabNames;
    private Context context;

    public PopViewAdapter(TabNames tabNames, Context context) {
        this.tabNames = tabNames;
        this.context = context;
    }

    @Override
    public int getCount() {
        return tabNames.getData().getChannels().size();
    }

    @Override
    public Object getItem(int position) {
        return tabNames.getData().getChannels().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(context).inflate(R.layout.item_only_text,null);
        TabNames.DataBean.ChannelsBean bean=tabNames.getData().getChannels().get(position);
        TextView tv= (TextView) convertView.findViewById(R.id.tv_item_only_text);
        View view=convertView.findViewById(R.id.view_item_only_text);
        tv.setText(bean.getName());
        if (position==selectItem){
            view.setVisibility(View.VISIBLE);
        }else {
            view.setVisibility(View.INVISIBLE);
        }
        return convertView;


    }
    public void setSelectItem(int selectItem){
        this.selectItem=selectItem;
    }
    private int selectItem=-1;
}


